function responseFormatter(req, res, next) {
 // 定义一个统一的响应函数
 
 res.success = (data, message = "请求成功",code = 200) => {
 
  res.status(200).json({

    code,

    message,

    data,

  });

};

res.fail = (data = null, message = "请求失败", code = 500) => {

  res.status(code).json({

    code,

    message,

    data,

  });

};

next();

}
  module.exports= responseFormatter